package com.test.ssm.controller;

import com.test.ssm.pojo.Script;
import com.test.ssm.service.ScriptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ScriptController {

    @Autowired
    private ScriptService scriptService;

    @RequestMapping("list.html")
    public ModelAndView list() {
        return new ModelAndView("index.jsp", "scriptList", scriptService.getScriptList(null));
    }

    @RequestMapping("update.html")
    public String update(Script script) {
        scriptService.updateScript(script);
        return "redirect:list.html";
    }
    @RequestMapping("delete.html")
    public String delete(Integer id) {
        scriptService.deleteScript(id);
        return "redirect:list.html";
    }
    @RequestMapping("pause.html")
    public String pause(Integer id) {
        scriptService.doPauseScript(id);
        return "redirect:list.html";
    }
    @RequestMapping("resume.html")
    public String resume(Integer id) {
        scriptService.doResumScriot(id);
        return "redirect:list.html";
    }
    @RequestMapping("add.html")
    public String add(Script script) {
        scriptService.addScript(script);
        return "redirect:list.html";
    }
}
